package logic;

import java.util.Iterator;
import java.util.List;


/**
 * this class is a representation of a Explosion.
 * @author Vossen en Konijnen group 2
 */

public class Explosion implements Actor 
{
    // Whether the Explosion is detonated or not.
    private boolean alive;
	// The Explosions field.
    private Field field;
    // The Explosions position in the field.
    private Location location;

	/**
	 * Create a Explosion.  
     * @param field The field currently occupied.
     * @param location The location within the field.
	 */
    public Explosion(Field field, Location location) 
	{
    	alive = false;
        this.field = field;
        setLocation(location);
	}

	@Override
	public void act(List<Actor> newActors){}

	 /**
     * Place the Explosion at the new location in the given field.
     * @param newLocation The Explosions new location.
     */
	@Override
    public void setLocation(Location newLocation)
    {
        if(location != null) {
            field.clear(location);
        }
        location = newLocation;
        field.place(this, newLocation);
    }

	@Override
	public boolean isActive() 
	{
		return alive;
	}

	@Override
	public Location getLocation() 
	{
		return location;
	}

	@Override
	public Field getField() 
	{
		return field;
		
	}
	
	/**
	 * Sets the Explosion detonated.
	 */
	public void setDead()
	{
		alive=false;
	}

}
